<p class='msview'>
	<span>
		<?php echo $this->session->flashdata('msview'); ?>
	</span>
</p>

<div class="header2"><p class="pHead"><?php echo $title; ?></p></div>
            <div class="contentMain">
                <form id="frmForm" method="POST" action="<?php echo base_url()?>back_end/category_product/deleteAll">
	                <div class="headerSearch tblHead" style="border-bottom:none;">
		                <table class="tbl_head">
		                    <tr>
		                    	<td><input type="submit" class="dlt" value="Xóa" name="delete" /></td>
		                    	<td><a href="<?php echo base_url()?>back_end/category_product/add"><img title="Thêm mới" alt="icon" src="<?php echo base_url(); ?>images/back_end/icon/add1.png"></a></td>
		                    	<td class="tag_add"><a href="<?php echo base_url()?>back_end/category_product/add">Thêm mới</a></td>
		                    	<td><span class="count_check"></span></td>
		                    </tr>
		                </table>
	                </div><!-- end headerSearch -->
	                
	                <table class="tablePr" width="100%">
	                	<tr class="trPr1">
		                    <td width="3%" class="tdPr7"><input type="checkbox" class="input_checkall" /></td>
		                    <td width="3%" class="tdPr7">
		                    	<a href="<?php echo base_url() ?>back_end/category_product/sort/id/<?php echo $sort; ?>">ID</a>
		                    </td>
		                    <td width="5%" class="tdPr7">
                                <a title="Click để sắp xếp" href="<?php echo base_url() ?>back_end/category_product/sort/level/<?php echo $sort; ?>">
			                		Cấp độ
			                	</a>
		                    </td>
                            <td width="19%" class="tdPr7">
		                    	<a title="Click để sắp xếp" href="<?php echo base_url() ?>back_end/category_product/sort/name/<?php echo $sort; ?>">
			                		Tên danh mục
			                	</a>
		                    </td>
		                    <td width="53%" class="tdPr7">
			                	<a title="Click để sắp xếp" href="<?php echo base_url() ?>back_end/category_product/sort/parent_id/<?php echo $sort; ?>">
			                		Danh mục cha
			                	</a>
		                    </td>
		                    <td width="8%" class="tdPr7">
			                		Thuộc tính danh mục
		                    </td>
		                    <td width="9%" class="tdPr7">
		                    	<a title="Click để sắp xếp" href="#">Tác vụ</a>
		                    </td>
		                </tr>
		                
		                <?php
		                	$count = 1; 
		                	foreach ($admin_category_product as $value) {
		                		$count += 1;	 
		                ?> 
			                <tr class="<?php if ($count%2) { echo 'trPr3'; } else { echo 'trPr2'; }  ?>">
			                    <td class="tdPr7"><input class="input_checkbox" type="checkbox"  value="<?php echo $value['id']; ?>" name="value_id[]"/></td>
			                    <td class="tdPr7">
			                    	<?php echo $value['id']; ?>
			                    </td>
			                    <td class="tdPr7">
			                    	<?php 
			                    		if ($value['level'] == 1) {
			                    			$color_vl = "color:#CF2E17; font-weight: bold;"; 
		                				} else {
		                					$color_vl = "color:#333"; 
		                				}
			                    	?>
		                    		<span style="<?php echo $color_vl; ?>">
		                    			<?php echo $value['level']; ?>
		                    		</span>
			                    </td>
			                    <td class="tdPr7" style="text-align: left;">
			                    	<span><?php echo $value['name']; ?></span>
			                    </td>
			                    <td class="tdPr7" style="text-align: left;">
			                    	<?php
			                    	
			                    		 	if ($value['level'] == 1) {
			                    		 		echo " ";
			                    		 	} else if ($value['level'] == 2) {
			                    		 			$vl_cate = explode(".", $value['root_path']);

													foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['0']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['1']) {
															echo "<a style='color:#CF2E17'>".$vl_ct['name']."</a>";
															break;
														}	
													}
			                    		 		
			                    		 	} else if ($value['level'] == 3) { 
													$vl_cate = explode(".", $value['root_path']);

													foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['0']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['1']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['2']) {
															echo "<a style='color:#CF2E17'>".$vl_ct['name']."</a>";
															break;
														}	
													}
			                    		 	} else if ($value['level'] == 4) { 
			                    		 			$vl_cate = explode(".", $value['root_path']);
			                    		 			
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['0']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['1']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['2']) {
															echo $vl_ct['name']. " >> ";
															break;
														}	
													}
			                    		 			foreach ($admin_category_product as $vl_ct ) {
														if ($vl_ct['id'] == $vl_cate['3']) {
															echo "<a style='color:#CF2E17'>".$vl_ct['name']."</a>";
															break;
														}	
													}
			                    		 	}
				 
			                    	?>
			                    </td>
			                    <td class="tdPr7">
			                    	<a class="pq" href="<?php echo base_url()?>back_end/category_product/per/<?php echo $value['id'];?>">Thuộc tính</a>
			                    </td>
			                    <td class="tdPr7">
			                    	<?php if($value['status'] == 1) { ?>
			                    		<a class="tag_action" href="<?php echo base_url()?>back_end/category_product/active/<?php echo $table.'-'.$value['id'].'-'.'0'.'-'.$table; ?>"><img src="<?php echo base_url()?>images/back_end/icon/check2.png" title="Trạng thái" alt="icon check" /></a>
			                    	<?php } else { ?>
			                 			<a class="tag_action" href="<?php echo base_url()?>back_end/category_product/active/<?php echo $table.'-'.$value['id'].'-'.'1'.'-'.$table; ?>"><img src="<?php echo base_url()?>images/back_end/icon/check.png" title="Trạng thái" alt="icon check" /></a>
			                    	<?php }?>
			                    	<a class="tag_action" href="<?php echo base_url()?>/back_end/category_product/edit/<?php echo $value['id']; ?>"><img src="<?php echo base_url()?>images/back_end/icon/edit-icon.gif" alt="Sửa" title="Sửa" /></a>
			                    	<a class="tag_action" href="<?php echo base_url()?>back_end/category_product/delete/<?php echo $value['id']; ?>"><img src="<?php echo base_url()?>images/back_end/icon/delete_png.png" title="Xóa"  alt="icon" /></a>
			                    </td>
		                    </tr>
	                    <?php } ?>
	                </table>
	                
	                <div class="headerSearch tblDel" style="border-top:none;">
	               		<table>
	                    	<tr>
                        		<td><input type="submit" class="dlt" value="Xóa" name="delete" /></td>
	                    		<td><a href="<?php echo base_url()?>back_end/category_product/add"><img title="Thêm mới" alt="icon" src="<?php echo base_url(); ?>images/back_end/icon/add1.png"></a></td>
	                    		<td class="tag_add"><a href="<?php echo base_url()?>back_end/category_product/add">Thêm mới</a></td>
	                        </tr>
	                    </table>
	                </div><!-- end headerSearch -->
                </form>
                
                <table class="tableLet2" style="margin:10px 10px 0 0;">
                    <tr>
                        <td width="60%" align="right" class="viewNumber" style="padding-right:10px;">
                        	<?php echo $this->pagination->create_links(); ?>
                        </td>
                    </tr>
                  </table>  
                  
            </div><!-- end contentMain -->